#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 110;

int n, m;
int f[N][N];
int g[N][N];
int dis[4][2] = {{-1, 0}, {0, 1}, {0, -1}, {1, 0}};

int dfs(int x, int y){
    if(~f[x][y]) return f[x][y];

    f[x][y] = 1;

    int temp = 0;
    for(int i = 0; i < 4; i ++){
        int nx = x + dis[i][0], ny = y + dis[i][1];
        if(nx < 1 || nx > n || ny < 1 || ny > m) continue;
        if(g[x][y] <= g[nx][ny]) continue;
        temp = max(temp, dfs(nx, ny));
    }

    f[x][y] += temp;
    return f[x][y];
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    memset(f, -1, sizeof f);
    cin >> n >> m;


    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            cin >> g[i][j];
        }
    }

    int maxv = 0;
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            if(f[i][j] == -1) {
                dfs(i, j);
            }
            maxv = max(maxv, f[i][j]);
        }
    }

    cout << maxv << '\n';



    return 0;
}